import $ from '../../utils/ajax.js';
import util from '../../utils/util.js';
const app = getApp();
Page({
    data: {
        content: [],
        list: {
            page: 1,
            size: 10,
        }
    },
    onLoad(options) {
    },
    onShow(){
        this.onPost();
    },
    omn({ currentTarget: { dataset:{id} }}) {
        wx.navigateTo({
            url: `/pages/region/detail/detail?storeId=${id}`
        })
        
    },
    onPost() {
        $.p(app.wxApp.url + 'agentincome/getAllAgentStoreCommission', { ...this.data.list }, app.onStrart, (res) => {
            let prime = [];
            if (res.data.page === 1) {
                prime = res.data.list;
            } else {
                prime = this.data.content.concat(res.data.list);
            }
            this.setData({
                content: prime
            })
            app.onShop();
        }, (res) => {
            util.showToast(res.data)
        })
    },
    onReachBottom(e) {
        this.setData({
            ['list.page']: this.data.list.page + 1
        }, () => {
            this.onPost();
        })
    }
})